package cn.xfdzx.android.apps.shop.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.contract.ItemClickListener;

/**
 * @author gzk
 * @date 2020/3/27 0027
 * description：全部订单
 */
public class AllOrderAdapter extends RecyclerView.Adapter {

    /**
     * 待支付两种
     */
    public static final int TYPE_DAI_PAY1 = 0;
    public static final int TYPE_DAI_PAY2 = 1;
    /**
     * 待配送两种
     */
    public static final int TYPE_DAI_PEI1 = 2;
    public static final int TYPE_DAI_PEI2 = 3;
    /**
     * 待收货两种
     */
    public static final int TYPE_DAI_SHOU1 = 4;
    public static final int TYPE_DAI_SHOU2 = 5;
    /**
     * 待评价两种
     */
    public static final int TYPE_DAI_PING1 = 6;
    public static final int TYPE_DAI_PING2 = 7;
    /**
     * 退换货两种
     */
    public static final int TYPE_TUI_1 = 8;
    public static final int TYPE_TUI_2 = 9;

    /**
     * 当前类型
     */
    public int mCurrentType = TYPE_DAI_PAY1;

    private Context mContext;
    private final LayoutInflater mLayoutInflater;

    public AllOrderAdapter(Context mContext) {
        this.mContext = mContext;
//        this.moduleBeanList = moduleBeanList;
        //以后用它来初始化布局
        mLayoutInflater = LayoutInflater.from(mContext);
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        if (viewType == TYPE_DAI_PAY1) {
            return new OrderViewHolder0(mContext, mLayoutInflater.inflate(R.layout.item_order_dai_pay1, null));
        } else if (viewType == TYPE_DAI_PAY2) {
            return new OrderViewHolder1(mContext, mLayoutInflater.inflate(R.layout.item_order_dai_pay2, null));
        } else if (viewType == TYPE_DAI_PEI1) {
            return new OrderViewHolder2(mContext, mLayoutInflater.inflate(R.layout.item_order_dai_pay3, null));
        } else if (viewType == TYPE_DAI_PEI2) {
            return new OrderViewHolder3(mContext, mLayoutInflater.inflate(R.layout.item_order_dai_pay4, null));
        } else if (viewType == TYPE_DAI_SHOU1) {
            return new OrderViewHolder4(mContext, mLayoutInflater.inflate(R.layout.item_order_dai_pay5, null));
        } else if (viewType == TYPE_DAI_SHOU2) {
            return new OrderViewHolder5(mContext, mLayoutInflater.inflate(R.layout.item_order_dai_pay6, null));
        } else if (viewType == TYPE_DAI_PING1) {
            return new OrderViewHolder6(mContext, mLayoutInflater.inflate(R.layout.item_order_dai_pay7, null));
        } else if (viewType == TYPE_DAI_PING2) {
            return new OrderViewHolder7(mContext, mLayoutInflater.inflate(R.layout.item_order_dai_pay8, null));
        } else if (viewType == TYPE_TUI_1) {
            return new OrderViewHolder8(mContext, mLayoutInflater.inflate(R.layout.item_home_shop, null));
        } else if (viewType == TYPE_TUI_2) {
            return new OrderViewHolder9(mContext, mLayoutInflater.inflate(R.layout.item_home_shop, null));
        }
        return null;
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
//        if (getItemViewType(position) == TYPE_BANNER) {
//            HomeBannerViewHolder homeBannerViewHolder = (HomeBannerViewHolder) holder;
//            homeBannerViewHolder.setData();
//        } else if (getItemViewType(position) == TYPE_DAY) {
//            HomeDayViewHolder homeDayViewHolder = (HomeDayViewHolder) holder;
//            homeDayViewHolder.setData();
//        } else if (getItemViewType(position) == TYPE_SHOP) {
//            HomeShopViewHolder homeDayViewHolder = (HomeShopViewHolder) holder;
//            homeDayViewHolder.setData();
//        }
    }

    @Override
    public int getItemCount() {
        return 8;
    }

    @Override
    public int getItemViewType(int position) {
        switch (position) {
            case TYPE_DAI_PAY1:
                mCurrentType = TYPE_DAI_PAY1;
                break;
            case TYPE_DAI_PAY2:
                mCurrentType = TYPE_DAI_PAY2;
                break;
            case TYPE_DAI_PEI1:
                mCurrentType = TYPE_DAI_PEI1;
                break;
            case TYPE_DAI_PEI2:
                mCurrentType = TYPE_DAI_PEI2;
                break;
            case TYPE_DAI_SHOU1:
                mCurrentType = TYPE_DAI_SHOU1;
                break;
            case TYPE_DAI_SHOU2:
                mCurrentType = TYPE_DAI_SHOU2;
                break;
            case TYPE_DAI_PING1:
                mCurrentType = TYPE_DAI_PING1;
                break;
            case TYPE_DAI_PING2:
                mCurrentType = TYPE_DAI_PING2;
                break;
            case TYPE_TUI_1:
                mCurrentType = TYPE_TUI_1;
                break;
            case TYPE_TUI_2:
                mCurrentType = TYPE_TUI_2;
                break;
        }
        return mCurrentType;
    }


    public class OrderViewHolder0 extends RecyclerView.ViewHolder {
        @BindView(R.id.rv_order_goods)
        RecyclerView rvOrderGoods;
        private Context mContext;

        public OrderViewHolder0(Context mContext, View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            this.mContext = mContext;
            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
            linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
            rvOrderGoods.setLayoutManager(linearLayoutManager);
            ItemAllOrderGoodsAdapter itemAllOrderGoodsAdapter = new ItemAllOrderGoodsAdapter(mContext);
            rvOrderGoods.setAdapter(itemAllOrderGoodsAdapter);

        }

    }

    public class OrderViewHolder1 extends RecyclerView.ViewHolder {
        @BindView(R.id.rv_order_goods)
        RecyclerView rvOrderGoods;
        private Context mContext;

        public OrderViewHolder1(Context mContext, View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            this.mContext = mContext;
            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
            linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
            rvOrderGoods.setLayoutManager(linearLayoutManager);
            rvOrderGoods.setItemAnimator(new DefaultItemAnimator());
            rvOrderGoods.setNestedScrollingEnabled(false);
            ItemOrderXfdGoodsAdapter itemOrderXfdGoodsAdapter = new ItemOrderXfdGoodsAdapter(mContext);
            itemOrderXfdGoodsAdapter.setOnItemClickListener(new ItemClickListener() {
                @Override
                public void onItemClick(int position) {

                }
            });
            rvOrderGoods.setAdapter(itemOrderXfdGoodsAdapter);
        }

    }

    public class OrderViewHolder2 extends RecyclerView.ViewHolder {
        private Context mContext;
        @BindView(R.id.rv_order_goods)
        RecyclerView rvOrderGoods;

        public OrderViewHolder2(Context mContext, View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            this.mContext = mContext;
            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
            linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
            rvOrderGoods.setLayoutManager(linearLayoutManager);
            ItemAllOrderGoodsAdapter itemAllOrderGoodsAdapter = new ItemAllOrderGoodsAdapter(mContext);
            rvOrderGoods.setAdapter(itemAllOrderGoodsAdapter);

        }

    }

    public class OrderViewHolder3 extends RecyclerView.ViewHolder {
        private Context mContext;
        @BindView(R.id.rv_order_goods)
        RecyclerView rvOrderGoods;

        public OrderViewHolder3(Context mContext, View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            this.mContext = mContext;
            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
            linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
            rvOrderGoods.setLayoutManager(linearLayoutManager);
            rvOrderGoods.setItemAnimator(new DefaultItemAnimator());
            rvOrderGoods.setNestedScrollingEnabled(false);
            ItemOrderXfdGoodsAdapter itemOrderXfdGoodsAdapter = new ItemOrderXfdGoodsAdapter(mContext);
            itemOrderXfdGoodsAdapter.setOnItemClickListener(new ItemClickListener() {
                @Override
                public void onItemClick(int position) {

                }
            });
            rvOrderGoods.setAdapter(itemOrderXfdGoodsAdapter);
        }

    }

    public class OrderViewHolder4 extends RecyclerView.ViewHolder {
        private Context mContext;
        @BindView(R.id.rv_order_goods)
        RecyclerView rvOrderGoods;

        public OrderViewHolder4(Context mContext, View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            this.mContext = mContext;
            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
            linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
            rvOrderGoods.setLayoutManager(linearLayoutManager);
            ItemAllOrderGoodsAdapter itemAllOrderGoodsAdapter = new ItemAllOrderGoodsAdapter(mContext);
            rvOrderGoods.setAdapter(itemAllOrderGoodsAdapter);
        }

    }

    public class OrderViewHolder5 extends RecyclerView.ViewHolder {
        private Context mContext;
        @BindView(R.id.rv_order_goods)
        RecyclerView rvOrderGoods;

        public OrderViewHolder5(Context mContext, View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            this.mContext = mContext;
            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
            linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
            rvOrderGoods.setLayoutManager(linearLayoutManager);
            rvOrderGoods.setItemAnimator(new DefaultItemAnimator());
            rvOrderGoods.setNestedScrollingEnabled(false);
            ItemOrderXfdGoodsAdapter itemOrderXfdGoodsAdapter = new ItemOrderXfdGoodsAdapter(mContext);
            itemOrderXfdGoodsAdapter.setOnItemClickListener(new ItemClickListener() {
                @Override
                public void onItemClick(int position) {

                }
            });
            rvOrderGoods.setAdapter(itemOrderXfdGoodsAdapter);
        }

    }

    public class OrderViewHolder6 extends RecyclerView.ViewHolder {
        private Context mContext;
        @BindView(R.id.rv_order_goods)
        RecyclerView rvOrderGoods;

        public OrderViewHolder6(Context mContext, View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            this.mContext = mContext;
            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
            linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
            rvOrderGoods.setLayoutManager(linearLayoutManager);
            ItemAllOrderGoodsAdapter itemAllOrderGoodsAdapter = new ItemAllOrderGoodsAdapter(mContext);
            rvOrderGoods.setAdapter(itemAllOrderGoodsAdapter);

        }

    }

    public class OrderViewHolder7 extends RecyclerView.ViewHolder {
        private Context mContext;
        @BindView(R.id.rv_order_goods)
        RecyclerView rvOrderGoods;

        public OrderViewHolder7(Context mContext, View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            this.mContext = mContext;
            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
            linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
            rvOrderGoods.setLayoutManager(linearLayoutManager);
            rvOrderGoods.setItemAnimator(new DefaultItemAnimator());
            rvOrderGoods.setNestedScrollingEnabled(false);
            ItemOrderXfdGoodsAdapter itemOrderXfdGoodsAdapter = new ItemOrderXfdGoodsAdapter(mContext);
            itemOrderXfdGoodsAdapter.setOnItemClickListener(new ItemClickListener() {
                @Override
                public void onItemClick(int position) {

                }
            });
            rvOrderGoods.setAdapter(itemOrderXfdGoodsAdapter);

        }

    }

    public class OrderViewHolder8 extends RecyclerView.ViewHolder {
        private Context mContext;

        public OrderViewHolder8(Context mContext, View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            this.mContext = mContext;

        }

    }

    public class OrderViewHolder9 extends RecyclerView.ViewHolder {
        private Context mContext;

        public OrderViewHolder9(Context mContext, View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            this.mContext = mContext;

        }

    }
}
